package com.tgy.algorithm.base._暴力递归;

public class _汉诺塔 {

    //
    public static void hanoi(int n) {
        doHanoi(n,"左","右","中");
    }

    public static void doHanoi(int n,String from,String to,String other) {
        if (n <= 1) {
            System.out.println(n + "  from " + from + "  to " + to);
            return;
        }
        doHanoi(n - 1 , from, other , to);
        System.out.println(n + "  from " + from + "  to " + to);
        doHanoi(n - 1 , other, to, from);
    }

    public static void main(String[] args) {
        hanoi(3);
    }
}
